package com.hzvictory.hotel_system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
//import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hzvictory.hotel_system.common.annotation.Log;
import com.hzvictory.hotel_system.common.core.controller.BaseController;
import com.hzvictory.hotel_system.common.core.domain.AjaxResult;
import com.hzvictory.hotel_system.common.enums.BusinessType;
import com.hzvictory.hotel_system.pojo.entity.Dishorder;
import com.hzvictory.hotel_system.service.IDishorderService;
//import com.hzvictory.hotel_system.common.utils.ExcelUtil;
import com.hzvictory.hotel_system.common.core.page.TableDataInfo;

/**
 * 菜品订单管理Controller
 *
 * @author hzvictory
 * @date 2025-07-25
 */
@RestController
@RequestMapping("/system/dishorder")
public class DishorderController extends BaseController
{
    @Autowired
    private IDishorderService dishorderService;

    /**
     * 查询菜品订单管理列表
     */
    //@PreAuthorize("@ss.hasPermi('system:dishorder:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dishorder dishorder)
    {
        startPage();
        List<Dishorder> list = dishorderService.selectDishorderList(dishorder);
        return getDataTable(list);
    }
    /**
     * 根据用户id查询菜品订单管理列表
     */
    @GetMapping("/list/{userId}")
    public TableDataInfo getInfoByUserId(@PathVariable("userId") Long userId)
    {
        startPage();
        List<Dishorder> list = dishorderService.selectDishorderListByUserId(userId);
        return getDataTable(list);
    }

    /**
     * 导出菜品订单管理列表
     */
    //@PreAuthorize("@ss.hasPermi('system:dishorder:export')")
//    @Log(title = "菜品订单管理", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, Dishorder dishorder)
//    {
//        List<Dishorder> list = dishorderService.selectDishorderList(dishorder);
//        ExcelUtil<Dishorder> util = new ExcelUtil<Dishorder>(Dishorder.class);
//        util.exportExcel(response, list, "菜品订单管理数据");
//    }

    /**
     * 获取菜品订单管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:dishorder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dishorderService.selectDishorderById(id));
    }

    /**
     * 新增菜品订单管理
     */
    //@PreAuthorize("@ss.hasPermi('system:dishorder:add')")
    @Log(title = "菜品订单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dishorder dishorder)
    {
        return toAjax(dishorderService.insertDishorder(dishorder));
    }

    /**
     * 修改菜品订单管理
     */
    //@PreAuthorize("@ss.hasPermi('system:dishorder:edit')")
    @Log(title = "菜品订单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dishorder dishorder)
    {
        return toAjax(dishorderService.updateDishorder(dishorder));
    }

    /**
     * 修改菜品订单状态 1待支付->2已支付
     */
    //@PreAuthorize("@ss.hasPermi('system:dishorder:edit')")
    //@Log(title = "菜品订单管理", businessType = BusinessType.UPDATE)
    @PutMapping("/status/{id}")
    public AjaxResult editStatusById(@PathVariable("id") Long id)
    {
        return toAjax(dishorderService.updateDishorderStatusById(id));
    }

    /**
     * 删除菜品订单管理
     */
    //@PreAuthorize("@ss.hasPermi('system:dishorder:remove')")
    @Log(title = "菜品订单管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dishorderService.deleteDishorderByIds(ids));
    }
}
